import React from 'react';

// 使用孙子组件
import Grandson from './Grandson';
import contextObj from './context';
import { useContext } from 'react';
// 语法: 
//  使用后 const data =  useContext(createContext())  data就是接收的祖先组件提供的数据
const Son = () => {
    const data = useContext(contextObj);
    //console.log('data', data);
    return (
        <div>
            <p>son组件</p>
            <ul>
                {
                    data.map((item, index) => <li key={index}>{item}</li>)
                }
            </ul>
            <Grandson></Grandson>
        </div>
    );
}

export default Son;
